local xuhe = fk.CreateSkill {

  name = "sk__xuhe",

  tags = { Skill.Compulsory, },

}



xuhe:addEffect(fk.CardUsing, {
  name = "sk__xuhe",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(xuhe.name) and data.tos then
      if target == player then
        return not player:isWounded() and table.find(data.tos, function (id)
          return id ~= player
        end)
      else
        return player:isWounded() and table.contains(data.tos, player)
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(xuhe.name)
    data.disresponsiveList = data.disresponsiveList or {}
    if target == player then
      room:notifySkillInvoked(player, xuhe.name, "offensive")
      table.insertTable(data.disresponsiveList, room:getOtherPlayers(player))
    else
      room:notifySkillInvoked(player, xuhe.name, "negative")
      table.insertIfNeed(data.disresponsiveList, player)
    end
    if player:getMark("sk__xuhe-turn") == 0 then
      local n = #data.tos
      if room:askForSkillInvoke(player, xuhe.name, nil, "#sk__xuhe-draw:::"..n) then
        room:setPlayerMark(player, "sk__xuhe-turn", 1)
        player:drawCards(n, xuhe.name)
      end
    end
  end,
})

return xuhe